package com.eastfair.venuebooking.enumeration;

import com.eastfair.annotation.base.BaseEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.stream.Stream;

/**
 * The enum Belong record operate type.
 *
 * @author dqq
 * @date 2022 /7/19
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "BelongRecordOperateType", description = "完成状态 #{NOT_FINISHED:未完成;HAVE_IN_HAND:进行中;COMPLETED:已完成-枚举")
public enum BelongRecordOperateTypeEnum implements BaseEnum {

    /**
     * 移入静默.
     */
    MOVE_IN_SILENCE("移入静默"),

    /**
     * 移入公海.
     */
    MOVE_IN_PUBLIC("移入公海"),

    /**
     * 自己领取.
     */
    TAKE("自己领取"),

    /**
     * 分配.
     */
    ASSIGN("分配"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;

    /**
     * 根据当前枚举的name匹配
     *
     * @param val the val
     * @param def the def
     * @return the belong record operate type enum
     */
    public static BelongRecordOperateTypeEnum match(String val, BelongRecordOperateTypeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    /**
     * Get belong record operate type enum.
     *
     * @param val the val
     * @return the belong record operate type enum
     */
    public static BelongRecordOperateTypeEnum get(String val) {
        return match(val, null);
    }

    /**
     * Eq boolean.
     *
     * @param val the val
     * @return the boolean
     */
    public boolean eq(BelongRecordOperateTypeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "NOT_FINISHED,HAVE_IN_HAND,COMPLETED", example = "NOT_FINISHED")
    public String getCode() {
        return this.name();
    }
}